/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
window.fbAsyncInit = function() {

    FB.init({
        appId  : '185600708137287',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });

    FB.getLoginStatus(function(response) {
        if (response.session) {
            // logged in and connected user, someone you know
            if(window.location == "http://pantsmp.zymichost.com/") {
                top.location.href = "https://www.facebook.com/dialog/oauth?client_id=185600708137287&redirect_uri=http://apps.facebook.com/pantsmp/&scope=email,read_stream";
                
            }
            else {
                var code = location.search.substring(6);

                FB.api(
                {
                    method: 'fql.query',
                    query: 'SELECT uid2, uid1 FROM friend WHERE uid1 = me()'
                },
                function(response) {
                    for(i=0;i<response.length;i++)
                        friend[i]=response[i].uid2;
                    $(document).ready(friendList());
                }
						
					
                );
                    
            }

        } else {
            // no user session available, someone you dont know
            top.location.href = "https://www.facebook.com/dialog/oauth?client_id=185600708137287&redirect_uri=http://apps.facebook.com/pantsmp/&scope=email,read_stream";

        }
    });


};

(function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
}())